package com.ioe.p2p.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author tanbo
 * @create 2023/10/8
 */
public class CommonUtil {

    /**
     * 日记打印
     * @param text 打印内容
     */
    public static void log(String text){
        System.out.println("===========" + text + "===========");
    }

    /**
     * 开启控制台输入
     * @return 输入字符
     */
    public static String enableConsolePrintln(){
        try(
            InputStreamReader is = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(is)
        ){
            return br.readLine();
        }
        catch(IOException e){
            throw new RuntimeException("控制台输入错误", e);
        }
    }

    /**
     * 判断字节是否是换行符
     * @param data 字节
     * @return 结果
     */
    public static boolean checkoutByteIsEnter(byte data){
        char b;
        // ascll码 接收和发送同一
        return (b = (char) data) == 14 || b == 10;
    }

}
